<?php
class ConfigurationController extends Zend_Controller_Action {
	
	public function init() {
		

	}

	public function indexAction(){
		echo "In Configuration Index";
		$this->getHelper('viewRenderer')->setNoRender();
	}

	public function updatekeysAction() {
		$form = new Macys_Form_Configuration_UpdateKeys();
		$confData = Macys_Base_Config::getInstance();
		if ($this->_request->isPost()) {
			$formData = $this->_request->getPost();
			if ($form->isValid($formData)) {
				$confData->setAllKeysFromInput($formData);
			}
			$form->populate($formData);
		}
		else {
			$form->populate($confData->getAllKeysForDisplay());
		}
		$this->view->form = $form;
	}

	public function updateoauthandurlsAction() {
		$form = new Macys_Form_Configuration_UpdateOauthAndUrls();
		$confData = Macys_Base_Config::getInstance();
		if ($this->_request->isPost()) {
			$formData = $this->_request->getPost();
			if ($form->isValid($formData)) {
				$confData->setOAuthAndUrlsFromDisplay($formData);
			}
			$form->populate($formData);
		}
		else {
			$form->populate($confData->getOAuthAndUrlsForDisplay());
		}

		$this->view->form = $form;
	}

	public function updateusercontextAction() {
		$form = new Macys_Form_Configuration_UpdateUserContext();
		$confData = Macys_Base_Config::getInstance();
		if ($this->_request->isPost()) {
			$formData = $this->_request->getPost();
			if ($form->isValid($formData)) {
				$confData->setManualUserContext($formData);
			}
			$form->populate($formData);
		}
		else {
			$val = $confData->getManualUserContext(TRUE);
			if($val)
			$form->populate($confData->getManualUserContext(TRUE));
		}

		$this->view->form = $form;
	}
	

}